package com.metaverse.backend.utils;
 
import java.util.HashMap;
import java.util.Map;
 

/**
 * @FileName Result.java
 * @Description: 返回数据
 *
 * 
 * 
 */
public class Result extends HashMap<String, Object> {
	private static final long serialVersionUID = 1L;
 
	public Result() {
		put("code", 20000);// 50008:非法的token; 50012:其他客户端登录了; 50014:Token 过期了;code为非20000是抛错 可结合自己业务进行修改
		put("message", "success");
	}
 
	public static Result error() {
		return error(-1, "未知异常，请联系管理员");
	}
 
	public static Result error(String message) {
		return error(0, message);
	}
 
	public static Result error(int code, String message) {
		Result result = new Result();
		result.put("code", code);
		result.put("message", message);
		return result;
	}
	
	public static Result error(int code, String message, Map<String, Object> map) {
		Result result = error(code, message);
		result.putAll(map);
		return result;
	}
 
	public static Result success(String message) {
		Result result = new Result();
		result.put("message", message);
		return result;
	}
 
	public static Result success(Map<String, Object> map) {
		Result result = new Result();
		result.putAll(map);
		return result;
	}
 
	public static Result success() {
		return new Result();
	}
 
	public Result put(String key, Object value) {
		super.put(key, value);
		return this;
	}
}